package com.chenchao.collection.stream;

import java.util.ArrayList;
import java.util.stream.Stream;

/**
 * @encoding : UTF-8
 * @Time : 2020/12/4 20:24
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.collection.stream.Test04.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * concat()与distinct()
 */
public class Test04 {
    public static void main(String[] args) {
        ArrayList<String> strings = new ArrayList<>();
        strings.add("喜羊羊");
        strings.add("美羊羊");
        strings.add("懒羊羊");
        strings.add("慢羊羊");
        strings.add("费羊羊");
        /*1.取前三个组成一个流*/
        Stream<String> stream01 = strings.stream().limit(3);
        /*2.跳过前两个组成一个流*/
        Stream<String> stream02 = strings.stream().skip(2);
        /*3.拼接流,Stream的静态方法*/
        Stream<String> concat = Stream.concat(stream01, stream02);
        /*4.去重*/
        concat.distinct().forEach(System.out::println);
    }
}
